package com.loveprogrammer.base.bean;

import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;

/**
 * @ClassName ServerConfig
 * @Description 服务基本配置类
 * @Author admin
 * @Date 2024/2/4 15:12
 * @Version 1.0
 */
@Data
public class ServerConfig {
    private static final Logger logger = LoggerFactory.getLogger(ServerConfig.class);

    private Integer port;
    private String channelType;
    private String protocolType;

    private Boolean sslOpen = false;
    private String sslType;
    private String sslPath;
    private String sslPassword;

    private static ServerConfig instance = null;

    private ServerConfig() {
    }

    public static ServerConfig getInstance() {
        if (instance == null) {
            instance = new ServerConfig();
            instance.init();
            instance.printServerInfo();
        }
        return instance;
    }

    private void init() {
        port = 8088;
        channelType = "NIO";
        protocolType = "TCP";
    }

    public void printServerInfo() {
        logger.info("**************Server INFO******************");
        logger.info("protocolType  : " + protocolType);
        logger.info("port          : " + port);
        logger.info("channelType   : " + channelType);
        logger.info("**************Server INFO******************");
    }

}
